from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
torch.manual_seed(0)

# 调用的huggingface 完整的模型
path = '/Users/a/.cache/huggingface/hub/models--openbmb--MiniCPM-2B-sft-bf16/snapshots/fe1d74027ebdd81cef5f815fa3a2d432a6b5de2a'
tokenizer = AutoTokenizer.from_pretrained(path)
model = AutoModelForCausalLM.from_pretrained(pretrained_model_name_or_path=path, torch_dtype=torch.bfloat16, trust_remote_code=True,)

responds, history = model.chat(tokenizer, "讲一个故事", temperature=0.3, top_p=0.3, eos_token_id=2, pad_token_id=2)
print(responds)